FROM golang:1.13-stretch as build
LABEL maintainer="Gitee"

ENV GO111MODULE=on

COPY ./ /go/src/gitee.com/oscstudio/gitee-exporter
WORKDIR /go/src/gitee.com/oscstudio/gitee-exporter

RUN go mod download \
    && go test ./... \
    && CGO_ENABLED=0 GOOS=linux go build -o /tmp/gitee-exporter

FROM alpine:3.10

RUN apk --no-cache add ca-certificates \
     && addgroup exporter \
     && adduser -S -G exporter exporter
USER exporter
COPY --from=build /tmp/gitee-exporter /usr/bin/gitee-exporter
ENV LISTEN_PORT=9190
EXPOSE 9190
ENTRYPOINT [ "/usr/bin/gitee-exporter" ]
